package com.projecy.common.utils;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.HashMap;
import java.util.Map;


public class ResultUtil {

    //成功
    public static ResponseEntity<Object> success(boolean code, Object data){
        System.out.println("成功结果");
        Map<String, Object> map = new HashMap<>(4);
        map.put("success", code);
        map.put("data", data);
        return new ResponseEntity<>(map, HttpStatus.OK);
    }

    //失败
    public static ResponseEntity<Object> fail(boolean code, String msg){
        System.out.println("失败结果");
        Map<String, Object> map = new HashMap<>(4);
        map.put("success", code);
        map.put("msg", msg);
        return new ResponseEntity<>(map, HttpStatus.OK);
    }
}
